package com.zhengxiang.onlinexamination.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhengxiang.onlinexamination.base.AjaxResult;
import com.zhengxiang.onlinexamination.entity.vo.WaitPaperVo;
import com.zhengxiang.onlinexamination.service.WaitPaperService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * 待考试(WaitPaper)表控制层
 *
 * @author
 * @since 2023-03-15 11:44:51
 */
@RestController
@RequestMapping("waitPaper")
public class WaitPaperController {
    /**
     * 服务对象
     */
    @Resource
    private WaitPaperService waitPaperService;

    /**
     * 待考试列表
     *
     * @param wp
     * @return
     */
    @PostMapping("queryAll")
    public AjaxResult queryAll(@RequestBody WaitPaperVo wp) {
        return AjaxResult.success(waitPaperService.queryAll(wp));
    }

    /**
     * 小程序待考列表
     */
    @GetMapping("queryWaitPaperByUser")
    public AjaxResult queryWaitPaperByUser(Page page) {

        return AjaxResult.success(waitPaperService.queryWaitPaperByUser(page));
    }

    /**
     * 下发考试
     *
     * @param wp
     * @return
     */
    @PostMapping("/saveWaitPaper")
    public AjaxResult saveWaitPaper(@RequestBody WaitPaperVo wp) throws IOException {
        waitPaperService.saveWaitPaper(wp);
        return AjaxResult.success();
    }

    /**
     * 试卷详情
     *
     * @param wp
     * @return
     */
    @GetMapping("/queryPaperInfo")
    public AjaxResult queryPaperInfo(WaitPaperVo wp) {
        return AjaxResult.success(waitPaperService.queryPaperInfo(wp));
    }


}

